<?php

///////////////// DO NOT TOUCH! /////////////////
define("START_TIME", get_microtime());///////////
define("ENGINE_VERSION", "1.01");////////////////
define("ENGINE_INT_VERSION", 101);///////////////
define("ENGINE_NAME", "PHPotter Ultimate Edition");//
define("ENGINE_EDITION", "forum");////////////////
define("LANGS", true);///////////////////////////
define("BETA", false);////////////////////////////
/////////////////////////////////////////////////

//////////// Changeable \/ //////////////////////
define("COOKIE_PREFIX", "phpbb3_sfq6t");//
/////////////////////////////// Changeable /\ ///

$level = "";
while(!file_exists($level."core.php")){
	$level .= "../";
}

define("SITE", $level);
define("SITE_SELF", basename($_SERVER['PHP_SELF']));
define("IMAGES_FOLDER", SITE."images/");
define("LANGS_FOLDER", SITE."langs/");
define("INCLUDES_FOLDER", SITE."includes/");
//define("MODULES_FOLDER", SITE."modules/");
define("TEMPLATES_FOLDER", SITE."templates/");
define("ADDONS_FOLDER", SITE."addons/");
if(file_exists(SITE."database_core.php")) { define("DATABASE", true); require_once SITE."database_core.php";}else{ define("DATABASE", false);}
if(file_exists(SITE."modules-core.php") && DATABASE) { define("MODULES_FOLDER", SITE."modules/"); require_once SITE."modules-core.php";} else { die("FATAL ERROR: Can`t include modules-core!"); } // NOTE: Modules need to work database, can`t be without
if(file_exists(SITE."templates/templates-core.php")) { define("TEMPLATES_FOLDER", SITE."templates/"); require_once TEMPLATES_FOLDER."templates-core.php"; } else { die("ERROR #100: Templates core not found"); }
if(file_exists(SITE."vip.php")) { define("VIP_ON", true); require_once SITE."vip.php"; }
//functions
function get_microtime() {
	list($usec, $sec) = explode(" ", microtime()); 
	return ((float)$usec + (float)$sec); 
}

function isnumeric($value) {
	if (!is_array($value)) {
		return (preg_match("/^[0-9]+$/", $value));
	} else {
		return false;
	}
}

function redirect($location, $script = false) {
	if (!$script) {
		header("Location: ".str_replace("&amp;", "&", $location));
		exit;
	} else {
		echo "<script type='text/javascript'>document.location.href='".str_replace("&amp;", "&", $location)."'</script>\n";
		exit;
	}
}

function check_special_chars($text, $die = true){
	$special_chars_array = array("<", ">", "\\");
	
	$texta = str_split($text);
	
	foreach($texta as $element){
		if(in_array($element, $special_chars_array)){
			if($die){
				die("Zle znaki");
				return false;
			}else{
				return false;
			}
		}
	}
	
	return true;
}

function return_with_a($text){
	$temp = $text;
	
	$a = 0;
	$b = 0;
	$array = array();
	while(strrpos($temp, "http://", $a) != false){
		$array[$b] = strrpos($temp, "http://", $a);
		$a = strrpos($temp, "http://", $a+1);
		$b++;
	}
	$ret = "";
	
	if(count($array) > 0){
		
		$c = 0;
		foreach($array as $element){
			while($c < $element){
				$ret .= $temp[$c];
				$c++;
			}
			
			$ret .= "<a href='";
			
			$d = $c;
			while($temp[$d] != "" or $temp[$d] != null){
				$ret .= $temp[$d];
				$d++;
			}
			
			$ret .= "'>";
			
			$d = $c;
			while($temp[$d] != "" or $temp[$d] != null){
				$ret .= $temp[$d];
				$d++;
			}
			
			$ret .= "</a>";
			
			$c = $d;
		}
	}else{
		$ret = $temp;
	}
	
	return $ret;
}

function get_month_name($month){
	if($month == "1"){
		return "Styczen";
	}
	if($month == "2"){
		return "Luty";
	}
	if($month == "3"){
		return "Marzec";
	}
	if($month == "4"){
		return "Kwiecien";
	}
	if($month == "5"){
		return "Maj";
	}
	if($month == "6"){
		return "Czerwiec";
	}
	if($month == "7"){
		return "Lipiec";
	}
	if($month == "8"){
		return "Sierpien";
	}
	if($month == "9"){
		return "Wrzesien";
	}
	if($month == "10"){
		return "Pazdziernik";
	}
	if($month == "11"){
		return "Listopad";
	}
	if($month == "12"){
		return "Grudzien";
	}
	return false;
}

function get_day_name($day){
	if($day == "1"){
		return "Poniedzialek";
	}
	if($day == "2"){
		return "Wtorek";
	}
	if($day == "3"){
		return "Sroda";
	}
	if($day == "4"){
		return "Czwartek";
	}
	if($day == "5"){
		return "Piatek";
	}
	if($day == "6"){
		return "Sobota";
	}
	if($day == "7"){
		return "Niedziela";
	}
	return false;
}


require_once INCLUDES_FOLDER."form.class.php";
require_once INCLUDES_FOLDER."user.class.php";
			
?>
